//
//  CustomHeaderView.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/16.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "CustomHeaderView.h"

@interface CustomHeaderView ()


@end

@implementation CustomHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        
        self.hostLogo = [[UIImageView alloc] init];
        self.guestLogo = [[UIImageView alloc] init];
        self.hostName = [[UILabel alloc] init];
        self.guestName = [[UILabel alloc] init];

        CGFloat commonWidth = kScreenIp6(80);
        [self addlogoNameViewWithFrame:CGRectMake(0, 0, commonWidth, commonWidth) logo:self.hostLogo name:self.hostName];
        [self addlogoNameViewWithFrame:CGRectMake(self.bounds.size.width - commonWidth, 0, commonWidth, commonWidth) logo:self.guestLogo name:self.guestName];
        
        self.score = [[UILabel alloc] initWithFrame:CGRectMake((self.bounds.size.width - commonWidth)/2, kScreenIp6(20), commonWidth, kScreenIp6(40))];
        self.score.textAlignment = NSTextAlignmentCenter;
        self.score.textColor = [UIColor colorWithRed:0.299 green:0.717 blue:0.174 alpha:1.000];
        self.score.font = [UIFont fontWithName:@"DB LCD Temp" size:24];
        self.score.adjustsFontSizeToFitWidth = YES;
        [self addSubview:_score];
        
        self.footerLine = [[UIImageView alloc] initWithFrame:CGRectMake(-kScreenIp6(30), commonWidth + kScreenIp6(30), kScreenWidth - kScreenIp6(20)*2, kScreenIp6(1))];
        self.footerLine.image = [UIImage imageNamed:@"scanline@2x"];
        [self addSubview:_footerLine];
    }
    return self;
}

- (void)addlogoNameViewWithFrame:(CGRect)frame logo:(UIImageView *)logo name:(UILabel *)name
{
    UIView *logoNameView = [[UIView alloc] initWithFrame:frame];
    
    CGFloat logoWidth = kScreenIp6(50);
    logo.frame = CGRectMake(kScreenIp6(15), 0, logoWidth, logoWidth);
    [logoNameView addSubview:logo];
    
    name.frame = CGRectMake(0, logoWidth, logoWidth + kScreenIp6(30), kScreenIp6(30));
    name.font = [UIFont systemFontOfSize:15];
    name.textAlignment = NSTextAlignmentCenter;
    name.adjustsFontSizeToFitWidth = YES;
    [logoNameView addSubview:name];
    
    [self addSubview:logoNameView];
}

@end
